﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Bangle.Model;
using Bangle.BLL;
using Bangle.Common;

public partial class System_Login_ModifyPassword : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btn_Submit_Click(object sender, EventArgs e)
    {
        if (this.txt_NewPassword.Value != this.txt_NewPassword2.Value)
        {
            base.Alert("重新输入密码不正确！");
            return;
        }
        if (this.txt_NewPassword.Value.Length < 6)
        {
            base.Alert("新密码长度不能少于6！");
            return;
        }
        Sys_User model = new Sys_User();
        Sys_UserBLL bll = new Sys_UserBLL();
        model = bll.GetModel(base.CurrentSession.UserID);
        if (MD5.EncryptMD5(this.txt_OldPassword.Value) == model.UserPwd)
        {
            model.UserPwd = MD5.EncryptMD5(this.txt_NewPassword.Value);

            bll.Update(model);

            Page.ClientScript.RegisterStartupScript(this.GetType(), "系统提示", "alert('操作成功！');parent.window.location.href = 'Logout.aspx'", true);
        }
        else
        {
            base.Alert("旧密码输入不正确！");
            return;
        }
    }
}
